<template>
	<div class="container">
		<el-page-header @back="goBack" :content="typename"></el-page-header>

		<el-row type="flex" justify="space-between" class="nav-bar">
			<el-col :span="3">
				<el-button type="primary" icon="el-icon-plus" plain @click="create">新建下级</el-button>
			</el-col>
			<el-col class="text-right">
				<el-form :inline="true" label-width="auto" class="nav-bar-form">
					<!-- <el-form-item>
						<el-cascader separator="-" @change="SelectSearchCity" filterable :props="{
							lazy: true,
							checkStrictly: true,
							lazyLoad: loadCity,
							label: 'name',
							value: 'id'
						}" placeholder="选择城市" style="width: 100%;margin-right: 20px" clearable></el-cascader>
					</el-form-item> -->
					<el-form-item>
						<el-input placeholder="关键词搜索" v-model="key" clearable prefix-icon="el-icon-search"
							@clear="getList"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" @click="getList">查询</el-button>
					</el-form-item>
				</el-form>
			</el-col>
		</el-row>

		<el-table :data="tableData" style="width: 100%" stripe>
			<el-table-column prop="name" label="名称">
			</el-table-column>
			<el-table-column prop="carbon" label="减碳量" width="200">
				<template slot-scope="scope">
					<!-- <div v-if="scope.row.carbon != 0"> -->
						<span>{{ scope.row.carbon }}%</span>
					<!-- </div> -->
					<!-- <div v-else>--</div> -->
				</template>
			</el-table-column>
			<!-- <el-table-column prop="fitprice" label="默认用户回收价格(元/公斤)" width="200">
				<template slot-scope="scope">
					<div v-if="scope.row.price.userprice != 0">
						<span>{{ scope.row.price.userprice }}</span>
					</div>
					<div v-else>--</div>
				</template>
			</el-table-column>
			<el-table-column prop="fitprice" label="默认散客回收价格(元/公斤)" width="200">
				<template slot-scope="scope">
					<div v-if="scope.row.price.fitprice != 0">
						<span>{{ scope.row.price.fitprice }}</span>
					</div>
					<div v-else>--</div>
				</template>
			</el-table-column>
			<el-table-column prop="enterpriseprice" label="默认客户组回收价格(元/公斤)" width="200">
				<template slot-scope="scope">
					<div v-if="scope.row.price.enterpriseprice != 0">
						<span>{{ scope.row.price.enterpriseprice }}</span>
					</div>
					<div v-else>--</div>
				</template>
			</el-table-column>
			<el-table-column prop="brotherprice" label="默认小哥价格(元/公斤)" width="200">
				<template slot-scope="scope">
					<div v-if="scope.row.price.brotherprice != 0">
						<span>{{ scope.row.price.brotherprice }}</span>
					</div>
					<div v-else>--</div>
				</template>
			</el-table-column>
			<el-table-column prop="packstationprice" label="预估出库价(元/公斤)" width="200">
				<template slot-scope="scope">
					<div v-if="scope.row.price.packstationprice != 0">
						<span>{{ scope.row.price.packstationprice }}</span>
					</div>
					<div v-else>--</div>
				</template>
			</el-table-column> -->
			<!-- <el-table-column label="允许修改散客价格" width="200">
				<template slot-scope="scope">
					<div v-if="scope.row.price">
						<span v-if="scope.row.price.alloweditfitprice">是</span>
						<span v-else>否</span>
					</div>
					<div v-else>--</div>
				</template>
			</el-table-column>
			<el-table-column label="允许修改客户组价格" width="200">
				<template slot-scope="scope">
					<div v-if="scope.row.price">
						<span v-if="scope.row.price.alloweditenterpriseprice">是</span>
						<span v-else>否</span>
					</div>
					<div v-else>--</div>
				</template>
			</el-table-column> -->
			<el-table-column prop="sort" label="排序" width="100">
			</el-table-column>
			<el-table-column prop="state" label="是否启用" width="100">
				<template slot-scope="scope">
					<!-- <span class="color-success" v-if="scope.row.usestate == '已启用'">{{ scope.row.usestate }}</span>
					<span class="color-danger" v-if="scope.row.usestate == '已隐藏'">{{ scope.row.usestate }}</span> -->
					<el-switch v-model="scope.row.state" @change="switchState($event, scope.row.id)"></el-switch>
				</template>
			</el-table-column>
			<el-table-column label="操作" fixed="right" width="180">
				<template slot-scope="scope">
					<el-button @click="edit(scope.row)" type="text" size="small">编辑</el-button>
					<el-button @click="getExpandPrice(scope.row.id, scope.row.price,scope.row)" type="text"
						size="small">设置价格</el-button>
					<!-- <el-button @click="set(scope.row)" type="text" size="small">设置价格</el-button> -->
					<el-button @click="del(scope.row.id)" type="text" size="small">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<!-- <div class="table-pagination">
			<el-pagination background layout="sizes, total, prev, pager, next" :total="total"
				:page-sizes="[10, 50, 100, 200]" :page-size="pageSize" :current-page="page" @current-change="pageChange"
				@size-change="handleSizeChange">
			</el-pagination>
		</div> -->

		<el-dialog :title="dialogType == 'add' ? `新建${typename}子类` : `编辑${typename}子类`" :visible.sync="dialogVisible" width="900px">
			<el-form ref="form" :model="form" :rules="rules" label-width="120px">
				<el-form-item label="名称" prop="name">
					<el-input v-model="form.name"></el-input>
				</el-form-item>
				<el-form-item label="减碳量%" prop="carbon">
					<el-input v-model="form.carbon"></el-input>
				</el-form-item>
				<el-form-item label="排序" prop="sort">
					<el-input v-model="form.sort"></el-input>
				</el-form-item>
				<el-form-item label="图片说明">
                    <cropper-upload :zoomScale='[1,1]' :isCropper="false" @getUpload="handleFilesSuccess" class="avatar-uploader">
                        <img v-if="form.pic" :src="fileURL + form.pic" class="avatar">
                        <div class="avatar-uploader-icon" v-else>
                            <div><i class="el-icon-plus"></i></div>
                            <div class="e-font-14">上传图片</div>
                        </div>
                    </cropper-upload>
                    <!-- <div class="tips e-p-t-10">建议上传尺寸比例为200*200 </div> -->
                </el-form-item>
				<!-- <el-form-item label="图文介绍">
					<Tinymce ref="editor" v-model="form.remarks" :height="350"></Tinymce>
				</el-form-item> -->

				<!-- <el-form-item label="状态">
					<el-radio-group v-model="form.state">
						<el-radio label="已启用"></el-radio>
						<el-radio label="已隐藏"></el-radio>
					</el-radio-group>
				</el-form-item>
                 -->
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取消</el-button>
				<el-button type="primary" @click="submitType('form')">确定</el-button>
			</span>
		</el-dialog>
		<!-- 设置价格 -->
		<el-dialog :title="classificationname+'-'+'设置价格'" :visible.sync="dialogVisiblePrice" width="800px">
			<el-form ref="priceForm" :model="priceForm" :rules="rules" label-width="140px">
				<el-form-item label="选择地区" prop="cityids">
					<div class="e-flex">
						<!-- <div v-if="priceForm.productId > 0 &&!editArea" class="e-flex-1">
							<span class="e-p-r-15">{{priceForm.areastrnames}}</span>
							<el-button type="text" icon="el-icon-edit" size="mini" @click="editArea = true">修改地区</el-button>
						</div>
						<div v-else class="e-flex-1">
							<el-cascader separator="-" @change="SelectCity" filterable :props="{
								lazy: true,
								checkStrictly: true,
								lazyLoad: loadCity,
								label: 'name',
								value: 'id'
							}" style="width: 100%;margin-right: 20px"></el-cascader>
						</div> -->
						<el-cascader separator="-" @change="SelectCity" filterable :props="{
							lazy: true,
							checkStrictly: true,
							multiple:false,
							lazyLoad: loadCity,
							label: 'name',
							value: 'id',
							multiple: true
						}" style="width: 100%;margin-right: 20px" v-model="selectCityID"></el-cascader>
					</div>
				</el-form-item>
				<el-form-item label="生效时间" prop="effectivedate">
					<el-date-picker v-model="priceForm.effectivedate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
						placeholder="选择日期" style="width: 100%;">
					</el-date-picker>
				</el-form-item>

				<el-form-item label="价格类型" prop="fitprice">
					<div class="flex e-m-b-15" style="align-items: center;">
						<el-input 
							type="number"
							:placeholder="`(${topTypePrice.minuserprice}~${topTypePrice.highuserprice}元/${isweighing?'公斤':'件'}内)`"
							:min="topTypePrice.minuserprice" :max="topTypePrice.highuserprice" class="e-flex-1 e-m-r-10" style="align-items: center"
							v-model="priceForm.userprice">
							<template slot="prepend">上门回收价-个人</template>
							<span slot="suffix" class="el-input__icon">元/{{ isweighing?'公斤':'件' }}</span>
						</el-input>
						<el-switch v-model="priceForm.allowedituserprice" active-text="允许修改上门回收价"></el-switch>
					</div>
					<div class="flex e-m-b-15" style="align-items: center;">
						<el-input type="number"
							:placeholder="`(${topTypePrice.minfitprice}~${topTypePrice.highfitprice}元/${isweighing?'公斤':'件'}内)`"
							:min="topTypePrice.minfitprice" :max="topTypePrice.highfitprice" class="e-flex-1 e-m-r-10"
							v-model="priceForm.fitprice">
							<template slot="prepend">站点回收价-线下</template>
							<span slot="suffix" class="el-input__icon">元/{{ isweighing?'公斤':'件' }}</span>
						</el-input>
						<el-switch v-model="priceForm.alloweditfitprice" active-text="允许修改站点回收价"></el-switch>
					</div>
					<div class="flex e-m-b-15" style="align-items: center;">
						<el-input type="number"
							:placeholder="`(${topTypePrice.minenterpriseprice}~${topTypePrice.highenterpriseprice}元/${isweighing?'公斤':'件'}内)`"
							class="e-flex-1 e-m-r-10" v-model="priceForm.enterpriseprice">
							<template slot="prepend">上门回收价-客户组</template>
							<span slot="suffix" class="el-input__icon">元/{{ isweighing?'公斤':'件' }}</span>
						</el-input>
						<el-switch v-model="priceForm.alloweditenterpriseprice" active-text="允许修改上门回收价"></el-switch>
					</div>
					<div class="flex e-m-b-15" style="align-items: center;">
						<el-input type="number"
							:placeholder="`(${topTypePrice.minbrotherprice}~${topTypePrice.highbrotherprice}元/${isweighing?'公斤':'件'}内)`"
							class="e-flex-1 e-m-r-10" v-model="priceForm.brotherprice">
							<template slot="prepend">站点回收价-线上</template>
							<span slot="suffix" class="el-input__icon">元/{{ isweighing?'公斤':'件' }}</span>
						</el-input>
						<el-switch v-model="priceForm.alloweditbrotherprice" active-text="允许修改站点回收价"></el-switch>
					</div>
					<div class="flex e-m-b-15" style="align-items: center;">
						<el-input type="number"
							:placeholder="`(${topTypePrice.minpackstationprice}~${topTypePrice.highpackstationprice}元/${isweighing?'公斤':'件'}内)`"
							class="e-flex-1 e-m-r-10" v-model="priceForm.packstationprice">
							<template slot="prepend">出库价</template>
							<span slot="suffix" class="el-input__icon">元/公斤</span>
						</el-input>
						<el-switch v-model="priceForm.alloweditpackstationprice" active-text="允许修改出库价"></el-switch>
					</div>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisiblePrice = false">取消</el-button>
				<el-button type="primary" @click="setPrice('priceForm')">确定</el-button>
			</span>
		</el-dialog>
		<el-dialog :title="classificationname+'-'+'价格列表'" :visible.sync="dialogVisiblePriceList" width="70%">
			<el-row type="flex" justify="space-between" class="e-p-b-15">
				<el-col :span="3">
					<el-button type="primary" icon="el-icon-plus" plain @click="set(priceId)">新建价格</el-button>
				</el-col>
				<el-col class="text-right">
					<el-form :inline="true" label-width="auto" class="nav-bar-form">
						<el-form-item>
							<el-cascader separator="-" @change="SelectPriceSearchCity" filterable :props="{
								lazy: true,
								checkStrictly: true,
								lazyLoad: loadCity,
								label: 'name',
								value: 'id'
							}" placeholder="选择城市" style="width: 100%;margin-right: 20px" clearable></el-cascader>
						</el-form-item>
						<el-form-item>
							<el-input placeholder="关键词搜索" v-model="priceSearch.key" clearable
								prefix-icon="el-icon-search" @clear="getExpandPrice(priceId)"></el-input>
						</el-form-item>
						<el-form-item>
							<el-button type="primary" @click="getExpandPrice(priceId,{},{name:classificationname})">查询</el-button>
						</el-form-item>
					</el-form>
				</el-col>
			</el-row>

			<el-table :data="priceList" :highlight-current-row="false" style="width: 100%">
				<el-table-column prop="citynames" label="地区价格">
					<template slot-scope="scope">
						<span>{{ scope.row.citynames.split(',')[scope.row.citynames.split(',').length - 1] }}</span>
					</template>
				</el-table-column>
				<el-table-column prop="userprice" :label="`上门回收价-个人(元/${isweighing?'公斤':'件'})`" width="200">
					<template slot-scope="scope">
						<span>{{ scope.row.userprice }}</span>
						<el-tag size="mini" v-if="scope.row.allowedituserprice">可修改价格</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="fitprice" :label="`站点回收价-线下(元/${isweighing?'公斤':'件'})`" width="200">
					<template slot-scope="scope">
						<span>{{ scope.row.fitprice }}</span>
						<el-tag size="mini" v-if="scope.row.alloweditfitprice">可修改价格</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="enterpriseprice" :label="`上门回收价-客户组(元/${isweighing?'公斤':'件'})`" width="200">
					<template slot-scope="scope">
						<span>{{ scope.row.enterpriseprice }}</span>
						<el-tag size="mini" v-if="scope.row.alloweditenterpriseprice">可修改价格</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="brotherprice" :label="`站点回收价-线上(元/${isweighing?'公斤':'件'})`" width="200">
					<template slot-scope="scope">
						<span>{{ scope.row.brotherprice }}</span>
						<el-tag size="mini" v-if="scope.row.alloweditbrotherprice">可修改价格</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="packstationprice" label="出库价(元/公斤)" width="170">
					<template slot-scope="scope">
						<span>{{ scope.row.packstationprice }}</span>
						<el-tag size="mini" v-if="scope.row.alloweditpackstationprice">可修改价格</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="effectivedate" label="生效时间" width="220">
				</el-table-column>
				<el-table-column prop="state" label="是否启用" width="100">
					<template slot-scope="scope">
						<el-switch v-model="scope.row.state"
							@change="switchPriceState($event, scope.row.id)"></el-switch>
					</template>
				</el-table-column>
			</el-table>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisiblePriceList = false">关闭</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
export default {
	layout: 'admin',
	head() {
		return {
			title: '废品下级分类' 
		}
	},
	data() {
		return {
			classificationname:'',//下级分级名字
			btn:false,//提交按钮
			rules: {
				fitprice: [
					{ required: true, message: '不能为空', trigger: 'blur' },
				],
				
				cityids: [
					{ required: true, message: '请输入地区', trigger: 'blur' },
				],
				effectivedate: [
					{ required: true, message: '请输入日期', trigger: 'blur' },
				],
				name: [
					{ required: true, message: '请输入名称', trigger: 'blur' },
					{ min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur' }
				],
				carbon: [
					{
						required: true,
						validator: (rule, value, callback) => {
							if (!value) {
								return callback(new Error('请输入数字值'));
							}
							if (value.length>3) {
								return callback(new Error('只能输入3位数'));
							}
							setTimeout(() => {
								value = parseFloat(value);
								if (!Number.isInteger(value)) {
									callback(new Error('请输入数字值'));
								} else {
									if (value > 100) {
										callback(new Error('最大值为100'));
									} else {
										callback();
									}
								}
							}, 1000);
						}
					},
				],
			},
			typename: '',
			isweighing: true,
			key: '',
			searchCityid: 0,
			page: 1,
			pageSize: 10,
			loading: false,
			total: 0,
			dialogVisible: false,
			dialogType: 'add',
			form: {
				pid: 0,
				carbon: "",
				name: '',
				remarks: '',
				typeId: 0,
				alloweditfitprice: false,
				alloweditenterpriseprice: false,
				pic: '',
				sort: 0,
				// state: '已启用',
				// photo: '',
				// price:[]
			},
			tableData: [],
			dialogVisiblePrice: false,
			dialogVisiblePriceList: false,
			editArea: false,
			priceForm: {
				productId: 0,
				// areastrnames: '',
				cityids: [], //城市id
				effectivedate: '', //生效时间
				fitprice: '', //散客回收价格
				enterpriseprice: '', //客户组回收价格
				brotherprice: '', //小哥价格
				packstationprice: '', //打包站收货价格
				alloweditfitprice: false, //允许修改散客价格
				alloweditenterpriseprice: false, //允许修改客户组价格
				alloweditbrotherprice: false, //允许修改小哥价格
				alloweditpackstationprice: false //允许修改回收站价格
			},
			priceList: [],
			priceId: 0,
			priceSearch: {
				key: '',
				cityId: 0
			},
			topTypePrice: { //当前小类归属类型默认价格（用户，小哥，回收站）
				alloweditbrotherprice: false,
				alloweditenterpriseprice: false,
				alloweditfitprice: false,
				alloweditpackstationprice: false,
				brotherprice: null,
				enterpriseprice: null,
				fitprice: null,
				highbrotherprice: null,
				highfitprice: null,
				highsettlementprice: null,
				minbrotherprice: null,
				minfitprice: null,
				minsettlementprice: null,
				packstationprice: null,
				minenterpriseprice: null,
				highenterpriseprice: null
			},
			selectCityID: null //设置价格选择地区
		}
	},
	watch: {
		dialogVisible(value) {
			if (!value) {
				this.form.name = ''
				this.form.carbon = ''
				this.form.remarks = ''
				this.form.alloweditfitprice = false
				this.form.alloweditenterpriseprice = false
				this.form.pic = ''
			}
		},
		dialogVisiblePrice(value) {
			if (!value) {
				this.btn = false
				this.selectCityID = null
				this.priceForm = {
					productId: 0,
					// areastrnames: '',
					cityids: [], //城市id
					effectivedate: '', //生效时间
					userprice: '', //用户回收价格
					fitprice: '', //散客回收价格
					enterpriseprice: '', //客户组回收价格
					brotherprice: '', //小哥价格
					packstationprice: '', //打包站收货价格
					alloweditfitprice: false, //允许修改散客价格
					alloweditenterpriseprice: false //允许修改客户组价格
					
				}
			}
		}
	},
	mounted() {
		this.form.typeId = this.$route.query.id
		this.typename = this.$route.query.type
		if(this.$route.query.isweighing == 'true'){
			this.isweighing = true
		}else{
			this.isweighing = false
		}
		this.getList()
	},
	methods: {
		goBack() {
			this.$router.go(-1)
		},
		//修改状态
		switchState(event, id) {
			this.$axios.post('/Waste/product/SetState', {
				ids: [id],
				state: event ? '已启用' : '已冻结'
			}).then((res) => {
				if (res.status == 0) {
					this.$message.success(res.msg);
				} else {
					this.$message.error(res.msg);
				}
			}).catch((err) => {
				this.getList()
			})
			// this.dialogType == 'edit'
			// this.submitType()
		},
		switchPriceState(event, id) {
			this.$axios.post('/Waste/price/SetState', {
				ids: [id],
				state: event ? '已启用' : '已冻结'
			}).then((res) => {
				if (res.status == 0) {
					this.$message.success(res.msg);
				} else {
					this.$message.error(res.msg);
				}
			}).catch((err) => {
				this.getExpandPrice(this.priceForm.productId)
			})
		},
		SelectCity(v) { //选择城市
			this.priceForm.cityids = []
			v.forEach((item) => {
				this.priceForm.cityids.push(item[item.length - 1])
			})
			console.log(this.priceForm.cityids)
			// this.priceForm.cityids = v;
			// this.priceForm.areastr = v.join(',');
		},
		SelectSearchCity(v) { //搜索选择城市
			this.searchCityid = v[v.length - 1];
		},
		SelectPriceSearchCity(v) { //价格搜索选择城市
			this.priceSearch.cityId = v[v.length - 1];
		},
		loadCity(node, resolve) { //加载城市
			this.$axios.post('/city/List', {
				pageIndex: 1,
				pageSize: 9999,
				pId: node.level == 0 ? '0' : node.value
			}).then((res) => {
				node = res.rows.map(function (c) {
					return {
						id: c.id,
						name: c.name,
						leaf: node.level >= 4
					}
				});
				resolve(node);
			})
		},
		handleFilesSuccess(res, file) {
			if (file.status === "success") {
				this.loading = false
				this.form.pic = res.path
			}
		},
		getList() {
			this.tableData = []
			this.loading = true

			// this.$axios.post(`/Waste/product/List?typeId=${this.form.typeId}&pid=${this.form.pid}`).then((res) => {
			this.$axios.get(`/Waste/product/List`, {
				params:{
					typeId: this.form.typeId
				}
			}).then((res) => {
				let datas = res.sort((a,b) => a.sort - b.sort)
				datas.forEach((item) => {
					if (item.usestate == '已启用') {
						item.state = true
					} else {
						item.state = false
					}
				})
				this.tableData = datas;
				this.total = res.total;
				this.loading = false
			}).catch(() => {
				this.loading = false
			})
		},
		submitType(formName) {
			let api = ''
			if (this.dialogType == 'add') {
				api = '/Waste/product/Create'
			}
			if (this.dialogType == 'edit') {
				api = '/Waste/product/Edit'
			}
			let param = {
				"id": this.form.id, //编辑时用id...
				"typeId": this.form.typeId, //创建时用largeTypeId...
				"name": this.form.name,
				"carbon": Number(this.form.carbon),
				"pic": this.form.pic,
				"sort": this.form.sort
			}
			this.$refs[formName].validate((valid) => {
				if (valid) {
					this.$axios.post(api, param).then((res) => {
						this.$message.success(res.msg);
						this.dialogVisible = false;
						this.getList()
					})

				} else {
					console.log('error submit!!');
					return false;
				}
			});


		},
		create() {
			this.dialogType = 'add'
			this.dialogVisible = true
		},
		edit(row) {
			console.log(row)
			this.dialogType = 'edit'
			this.dialogVisible = true
			this.form.id = row.id
			this.form.name = row.name
			this.form.carbon = row.carbon

			this.form.sort = row.sort
			this.form.pic = row.pic
			// this.form.state = row.state
			// this.form.photo = row.img
		},
		set(id) { //设置价格
			this.dialogVisiblePrice = true
			this.priceForm.productId = id
		},
		setPrice(formName) { //提交价格
			// if(!this.priceForm.fitprice){
			// 	this.$message.error('请输入散客价格');
			// 	return
			// }
			this.$refs[formName].validate((valid) => {
          if (valid) {
			if(!this.priceForm.enterpriseprice){
				this.$message.error('请输入上门回收价-客户组');
				return
			}
			if(!this.priceForm.brotherprice){
				this.$message.error('请输入站点回收价-线上');
				return
			}
			// if(!this.priceForm.packstationprice){
			// 	this.$message.error('请输入结算价格');
			// 	return
			// }
			this.btn = true
			this.$axios.post('/Waste/Price/Create', this.priceForm).then((res) => {
				this.$message.success(res.msg);
				this.dialogVisiblePrice = false;
				this.dialogVisiblePriceList = false;
				
				// this.getExpandPrice(this.priceForm.productId)
			})
          } else {
            console.log('error submit!!');
            return false;
          }
        });
			
		},
		search() {
			this.getList()
		},
		pageChange(e) { // 页码切换事件
			this.page = e;
			this.getList()
		},
		handleSizeChange(val) {
			this.page = 1;
			this.pageSize = val;
			this.getList()
		},
		del(id) {
			this.$confirm('此操作将删除该分类, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.$axios.post('/Waste/product/Delete?Id=' + id).then((res) => {
					this.$message.success(res.msg);
					this.getList()
				})
			})
		},
		getExpandPrice(id, price = {},row) { //展开获取价格列表

			this.classificationname = row.name
			console.log(row)
			this.topTypePrice = price
			this.dialogVisiblePriceList = true
			this.priceId = id
			this.$axios.post('/Waste/Price/List', {
				pageIndex: 1,
				pageSize: 999,
				productId: id,
				key: this.priceSearch.key,
				cityId: this.priceSearch.cityId
			}).then((res) => {
				let rows = res.rows
				rows.forEach((item) => {
					if (item.usestate == '已启用') {
						item.state = true
					} else {
						item.state = false
					}
				})
				this.priceList = rows
			})
		},
		switchAlloweditfitprice(event, type) { //是否允许修改散客价格
			console.log(event)
			// this.dialogType == 'edit'
			// this.submitType()
		},
		switchAlloweditenterpriseprice() {

		}
	}
}
</script>

<style lang="scss">
.nav-bar {
	padding: 45px 0 0;
}

.table-expand {
	background-color: #f1f1f1;

	.item {
		border-bottom: 1px solid var(--border-light);
		padding: 10px;

		&:last-child {
			border-bottom: 0;
		}

		.city {
			font-size: 16px;
			font-weight: 500;
			margin-bottom: 10px;
			color: var(--dark);
		}

		.price-list {
			display: flex;
			color: var(--grey);

			.pl-item {
				margin-right: 15px;

				em {
					font-size: 18px;
					color: var(--orange);
					font-weight: bold;
				}
			}
		}
	}
}
</style>
